#include"comm.hpp"

int main()
{
    int wfd=open(PATH,O_WRONLY);//打开，返回文件描述符
    if(wfd<0)
    {
         cerr<<"open fifo fail... errno: "<<errno<<",errstring: "<<strerror(errno)<<endl;
         return -1;
    }
    //下面这句只有
    cout<<"open success..."<<endl;
    cout<<"Please Enter Your Message!"<<endl;
    string buffer;
    while(1)
    {
        getline(cin,buffer);//cin遇到“ ”会终止
        if(buffer=="quit")
            break;
        int n=write(wfd,buffer.c_str(),buffer.size());
        if(n<0)
        {
            cerr<<"write fifo fail... errno: "<<errno<<",errstring: "<<strerror(errno)<<endl;
            break;
        }
    }
    close(wfd);
    return 0;
}